﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BankLibrary
{
    public partial class BankUIForm : Form
    {
        public BankUIForm()
        {
            InitializeComponent();
        }

        protected int TextBoxCount = 4;

        public enum TextBoxIndices
        {
            ACCOUNT,
            FIRST,
            LAST,
            BALANCE
        }

        public void ClearTextBoxes()
        {
            foreach (Control guiControl in Controls)
            {
                if ( guiControl is TextBox)
                    ((TextBox)guiControl).Clear();
            }
        }

        public void SetTextBoxValues(string[] values)
        {
            if (values.Length != TextBoxCount)
            {
                throw (new ArgumentException("There must be " + (TextBoxCount) + "strings in the array"));
            }
            else
            {
                accountTextBox.Text = values[(int) TextBoxIndices.ACCOUNT];
                firstNameTextBox.Text = values[(int) TextBoxIndices.FIRST];
                lastNameTextBox.Text = values[(int) TextBoxIndices.LAST];
                balanceTextBox.Text = values[(int) TextBoxIndices.BALANCE];
            }
        }

        public string[] GetTextBoxValues()
        {
            string[] values = new string[TextBoxCount];

            values[(int) TextBoxIndices.ACCOUNT] = accountTextBox.Text;
            values[(int) TextBoxIndices.FIRST] = firstNameTextBox.Text;
            values[(int) TextBoxIndices.LAST] = lastNameTextBox.Text;
            values[(int) TextBoxIndices.BALANCE] = balanceTextBox.Text;

            return values;
        }
    }
}
